{template "header.html"}
<script type="text/javascript">
$(function() {
	$(".table_form tr>th").attr("width", 150);
	$(".dr_000 tr").last().addClass("dr_border_none");
	{if $error}
	art.dialog.tips('<font color=red>{$error.msg}</font>', 3);
	d_tips('{$error['error']}', 0);
	{/if}
	{if $result}
	art.dialog.tips('{$result}', 3, 1);
	{/if}
	{if $create}
	$.post('{$create}&rand='+Math.random(),{ }, function(data){
	});
	{/if}
    //每隔5秒保存表单数据
    {if !$data.id && !$did}
    setInterval("dr_save_add_data()", 5000);
    {/if}
    // 加载草稿
    $("#dr_cgbox").mouseover(function(){
        $(".dr_cgbox").show();
    }).mouseout(function(){
        $(".dr_cgbox").hide();
    });
    // 删除草稿数据
    $(".dr_cgbox_delete").click(function(){
        var did = $(this).attr("did");
        var num = parseInt($("#dr_cg_nums").html());
        $.ajax({
            type: "POST",
            dataType:"json",
            url: memberpath+'index.php?c=api&m=ajax_delete_draft&sid={SITE_ID}&dir={APP_DIR}&did='+did,
            success: function(data) {
                if (data == did) {
                    $("#dr_cgbox_"+did).remove();
                    $("#dr_cg_nums").html(num - 1);
                } else {
                    dr_tips(data);
                }
            },
            error: function(HttpRequest, ajaxOptions, thrownError) { }
        });
    });
    $(".dr_cgbox_select").click(function(){
        var did = $(this).attr("did");
        window.location.href = '{$draft_url}&did='+did;
    });
    // 自动保存草稿
    {if $did}
        setInterval("dr_save_draft_data()", 5000);
    {/if}
});
// 动态保存草稿数据
function dr_save_draft_data() {
    $.ajax({
        type: "POST",
        dataType:"json",
        url: memberpath+'index.php?c=api&m=ajax_save_draft&sid={SITE_ID}&dir={APP_DIR}&did={$did}',
        data: $("#myform").serialize(),
        success: function(data) { },
        error: function(HttpRequest, ajaxOptions, thrownError) { }
    });
}
// 动态保存表单数据
function dr_save_add_data() {
    $.ajax({
        type: "POST",
        dataType:"json",
        url: memberpath+'index.php?c=api&m=ajax_save_add&dir={APP_DIR}_extend',
        data: $("#myform").serialize(),
        success: function(data) { },
        error: function(HttpRequest, ajaxOptions, thrownError) { }
    });
}
</script>
<form action="" method="post" name="myform" id="myform">
<input name="action" id="dr_action" type="hidden" value="back" />
<div class="subnav">
	<div class="content-menu ib-a blue line-x">
		{$menu}
	</div>
	<div class="bk10"></div>
    <div class="table-list col-tab">
            {if $draft_list}
        <ul class="tabBut2 cu-li">
            <li class="cg li" id="dr_cgbox">
                {lang('html-790')}（<span id="dr_cg_nums">{count($draft_list)}</span>）
                <fieldset class="dr_cgbox" style="display:none">
                    <div class="picList">
                        <ul class="cg_items" style="max-height: 400px;overflow-y: auto;">
                            {loop $draft_list $t}
                            <li id="dr_cgbox_{$t.id}">
                                <a href="javascript:;" class="dr_cgbox_delete" did="{$t.id}" title="{lang('del')}"><img align="absmiddle" src="{SITE_URL}dayrui/statics/images/b_drop.png"></a>
                                <span>{dr_date($t.inputtime)}</span>
                                <a href="javascript:;" class="dr_cgbox_select" did="{$t.id}">{$t.name}</a>
                            </li>
                            {/loop}
                        </ul>
                    </div>
                </fieldset>
            </li>
        </ul>
            {/if}
		<div class="bk10"></div>
        <div class="dr_table">
			<fieldset>
			<legend>{lang('mod-601')}</legend>
			<table width="100%" class="table_form dr_000">
        <tr>
            <th width="200">{lang('html-214')}： </th>
            <td><font color="#777">{$content.title}</font></td>
        </tr>
        {$myfield}
        {if !$data.id && $ci->get_cache('module-'.SITE_ID.'-'.APP_DIR, 'setting', 'syn2')}
        <tr>
            <th width="200">{lang('m-113')}： </th>
            <td>
			<input name="qq_share" type="checkbox" checked="checked" value="1" />
			<label>腾讯微博</label>
            {if !$member.oauth.qq}<label style="color:#FF0000">（请进入会员中心-账户-快捷登陆，绑定QQ账户）</label>{/if}
			&nbsp;&nbsp;
			<input name="sina_share" type="checkbox" checked="checked" value="1" />
			<label>新浪微博</label>
            {if !$member.oauth.sina}<label style="color:#FF0000">（请进入会员中心-账户-快捷登陆，绑定新浪账户）</label>{/if}
            </td>
        </tr>
        {/if}
        </table>
        </div>
    </div>
</div>
<div class="fixed-bottom">
    <div class="fixed-but text-c">
        <div class="button"><input value="{lang('html-789')}" type="submit" name="submit" class="cu" onclick="$('#dr_action').val('draft')" style="width:100px;" /></div>
        <div class="button"><input value="{lang('html-362')}" type="submit" name="submit" class="cu" onclick="$('#dr_action').val('back')" style="width:100px;" /></div>
        {if !$data.id}
        <div class="button"><input value="{lang('html-363')}" type="submit" name="submit" class="cu" onclick="$('#dr_action').val('continue')" style="width:100px;" /></div>
        {/if}
    </div>
</div>
</form>
{template footer.html}